#include <cstdio>
#include <algorithm>
using namespace std;
const int N = 500005;
int n, c[N];
long long ans;
struct node {
	int val, id;
}tmp[N];
int lowbit (int x) {
	return x & (-x);
}
void update (int x, int v) {
	for (int i = x; i <= n; i += lowbit(i)) {
		c[i] += v;
	}
}
int query (int x) {
	int sum = 0;
	for (int i = x; i > 0; i -= lowbit(i)) {
		sum += c[i];
	}
	return sum;
}
bool cmp (node x, node y) {
	if (x.val == y.val) {
		return x.id > y.id;
	}
	return x.val > y.val;
}
int main() {
	scanf ("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf ("%d", &tmp[i].val);
		tmp[i].id = i;
	}
	sort (tmp + 1, tmp + n + 1, cmp);
	for(int i = 1; i <= n; i++){
        update (tmp[i].id, 1);
        ans += query(tmp[i].id - 1);
    }
	printf ("%d\n", ans);
	return 0;
}
